<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <form>
        用户名:<input type="text" name="username" id="username"> <br>
        密码:<input type="password" name="password" id="password"> <br>
        <input id="btn" type="button" value="注册" >
    </form>
</body>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
    window.onload=function () {
        var btn = document.querySelector("#btn");
        var usernameNode = document.querySelector("#username");
        var passwordNode = document.querySelector("#password");
        btn.onclick=async function () {
            var username = usernameNode.value;
            var password = passwordNode.value;
            var obj = {
                name:username,
                password:password
            };
            var res = await axios.post('http://127.0.0.1:8888/user/addUser', obj);

            //注册成功
            window.location.href = "http://127.0.0.1:8888/test.html"
        }
    }
</script>
</html>